using System;
using Microsoft.SPOT;

namespace PandaDataLogger
{
  public class Message
  {
    const string sep = "|";
    const string end = "\r\n";

    public string SenderID { get; set; }
    public string TargetID { get; set; }
    public string Command { get; set; }
    public int ParamsCount { get; set; }
    public string[] Params { get; set; }

    public Message()
    {
      SenderID = null;
      TargetID = null;
      Command = null;
      ParamsCount = 0;
      Params = null;
    }

    public override string ToString()
    {
      string ts = string.Empty;
      if (ParamsCount == 0)
        ts = SenderID + sep + TargetID + sep + Command + sep + ParamsCount + end;
      else
      {
        ts = SenderID + sep + TargetID + sep + Command + sep + ParamsCount + sep;
        for (int x = 0; x < ParamsCount; x++)
        {
          ts += Params[x] + (x < ParamsCount ? sep : string.Empty);
        }
        ts += end;
      }
      return ts;
    }



  }
}
